{% extends "djepoUserBundle::layout.html.twig" %}

{% block fos_user_content %}

{% if websiteUseFacebookLogin %}

        {{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();', 'culture': 'fr-FR'}) }}
        <script>
            function goLogIn(){
                window.location = "{{ path('_security_check') }}";
            }

            function onFbInit() {
                if (typeof(FB) != 'undefined' && FB != null ) {
                    FB.Event.subscribe('auth.statusChange', function(response) {
                        if (response.session || response.authResponse) {
                            setTimeout(goLogIn, 500);
                        } else {
                            window.location = "{{ path('_security_logout') }}";
                        }
                    });
                }
            }
        </script>
{% endif %}

{% if error %}
    <div class="notice error col_4">
        <i class="icon-remove-sign icon-large"></i>
        {{ error|trans({}, 'FOSUserBundle') }}
        <a href="#close" class="icon-remove"></a>
    </div>
{% endif %}

<form action="{{ path("fos_user_security_check") }}" method="post">
    <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />

    <label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
    <input type="text" id="username" name="_username" value="{{ last_username }}" required="required" />

    <label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
    <input type="password" id="password" name="_password" required="required" />

    <input type="checkbox" id="remember_me" name="_remember_me" value="on" />
    <label for="remember_me">{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>

    <input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
</form>
        
        <div id="social_login" class="clearfix">
        {% if websiteUseFacebookLogin %}        
            {{ facebook_login_button({'autologoutlink': false}) }}                
        {% endif %}
    </div>
{% endblock fos_user_content %}
